﻿using System;
using System.Runtime.Serialization;
using System.IO;
namespace Skyper.Shared {
	[DataContract(Name = "Base")]
	public abstract class BaseModel : IState {
		#region Fields
		private static DataContractSerializer serializer;
		#endregion
		#region Constructor
		public BaseModel() {
			if (serializer == null) {
				serializer = this.CreateSerializer();
			}
		}
		#endregion
		#region Protected
		/// <summary>
		/// Creates the serializer.
		/// </summary>
		/// <returns></returns>
		protected abstract DataContractSerializer CreateSerializer();
		protected static DataContractSerializer GetSerializer() {
			
			return serializer;
		}
		#endregion
		#region Public
		public abstract bool Suspend(Stream stream);
		public abstract bool Resume(Stream stream);
		#endregion
		#region Property
		public DataContractSerializer Serializer {
			get {
				return serializer;
			}
		}
		#endregion
	}
}
